﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DTcms.Common;

namespace DTcms.Web.UI
{
    /// <summary>
    /// 工长
    /// </summary>
    public partial class BasePage : System.Web.UI.Page
    {
        #region 工长
        /// <summary>
        /// 工长列表
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="orderby">排序</param>
        /// <returns>DataTable</returns>
        protected DataTable get_foreman_list(int top, string strwhere, string orderby)
        {
            DataTable dt = new BLL.foreman_user().GetList(top, strwhere, orderby).Tables[0];
            return dt;
        }

        /// <summary>
        /// 文章分页列表(可排序)
        /// </summary>
        /// <param name="page_size">分页大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="orderby">排序</param>
        /// <param name="totalcount">总记录数</param>
        /// <param name="_key">URL配置名称</param>
        /// <param name="_params">传输参数</param>
        /// <returns>DataTable</returns>
        protected DataTable get_foreman_list( int page_size, int page_index, string strwhere, string orderby, out int totalcount, out string pagelist, string _key, params object[] _params)
        {
            DataTable dt = new DataTable();
            totalcount = 0;
            pagelist = "";

            dt = new BLL.foreman_user().GetList(page_size, page_index, strwhere, orderby, out totalcount).Tables[0];
            pagelist = Utils.OutPageList(page_size, page_index, totalcount, linkurl(_key, _params), 8);
            return dt;
        }

        /// <summary>
        /// 返回工长实体类
        /// </summary>
        protected Model.foreman_user get_foreman_model(int user_id)
        {
            var model=new BLL.foreman_user().GetModel("user_id="+user_id);
            model.user=new BLL.users().GetModel(user_id);
            return model;
        }

        /// <summary>
        /// 获取工作年限-整数
        /// </summary>
        /// <param name="workyear"></param>
        /// <returns></returns>
        protected string get_foreman_work(int workyear)
        {
            string strworkyear = "";
            switch (workyear)
            {
                case 1:
                    strworkyear = "1-3年";
                    break;
                case 2:
                    strworkyear = "3-5年";
                    break;
                case 3:
                    strworkyear = "5-10年";
                    break;
                case 4:
                    strworkyear = "10年以上";
                    break;
            }
            return strworkyear;
        }
        /// <summary>
        /// 获取工作年限-文本
        /// </summary>
        /// <param name="workyear"></param>
        /// <returns></returns>
        protected string get_foreman_work(string workyear)
        {
            string strworkyear = "";
            switch (workyear)
            {
                case "1":
                    strworkyear = "1-3年";
                    break;
                case "2":
                    strworkyear = "3-5年";
                    break;
                case "3":
                    strworkyear = "5-10年";
                    break;
                case "4":
                    strworkyear = "10年以上";
                    break;
            }
            return strworkyear;
        }
        /// <summary>
        /// 获取工地质量等级
        /// </summary>
        /// <param name="workyear"></param>
        /// <returns></returns>
        protected string get_fore_grade(string foregrade)
        {
            string strforegrade = "";
            switch (foregrade)
            {
                case "1":
                    strforegrade = "优秀";
                    break;
                case "2":
                    strforegrade = "良好";
                    break;
                case "3":
                    strforegrade = "一般";
                    break;
            }
            return strforegrade;
        }

        /// <summary>
        /// 质量保障
        /// </summary>
        /// <param name="workyear"></param>
        /// <returns></returns>
        protected string get_fore_safe(string fore_safe)
        {
            string strforegrade = "";
            string str= "";
            string[] array = fore_safe.Split(',');
            foreach (string i in array)
            {
                switch (i)
                {
                    case "1":
                        str = "<b>质量保障</b>";
                        break;
                    case "2":
                        str = "<b>工时保障</b>";
                        break;
                    case "3":
                        str = "<b>服务保障</b>";
                        break;
                }
                strforegrade += str;
            }
            
            return strforegrade;
        }

        #endregion

        #region 预约
        /// <summary>
        /// 预约列表
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="orderby">排序</param>
        /// <returns>DataTable</returns>
        protected DataTable get_apply_list(int top, string strwhere, string orderby)
        {
            DataTable dt = new BLL.foreman_apply().GetList(top, strwhere, orderby).Tables[0];
            return dt;
        }
        /// <summary>
        /// 文章分页列表(可排序)
        /// </summary>
        /// <param name="page_size">分页大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="orderby">排序</param>
        /// <param name="totalcount">总记录数</param>
        /// <param name="_key">URL配置名称</param>
        /// <param name="_params">传输参数</param>
        /// <returns>DataTable</returns>
        protected DataTable get_apply_list(int page_size, int page_index, string strwhere, string orderby, out int totalcount, out string pagelist, string _key, params object[] _params)
        {
            DataTable dt = new DataTable();
            totalcount = 0;
            pagelist = "";

            dt = new BLL.foreman_apply().GetList(page_size, page_index, strwhere, orderby, out totalcount).Tables[0];
            pagelist = Utils.OutPageList(page_size, page_index, totalcount, linkurl(_key, _params), 8);

            return dt;
        }
        #endregion
    }
}
